package com.jiahuiwen.singleton;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 本程序是验证不使用单例模式读取配置文件的信息.
 * 
 * @author jiahui.wen
 * @version 1.0
 */
class AppConfig {

	private String parameterA;
	private String parameterB;
	
	
	
	public String getParameterA() {
		return parameterA;
	}



	public String getParameterB() {
		return parameterB;
	}

	

	public AppConfig() {
		super();
		//读取配置文件信息
		readConfig();
	}



	private void readConfig() {
		// TODO Auto-generated method stub
		Properties p = new Properties();
		InputStream in = null;
		try{
			// 将配置文件输入到inputStream流
			in = AppConfig.class.getResourceAsStream("AppConfig.properties");
			p.load(in);
			this.parameterA = p.getProperty("paramA");
			this.parameterB = p.getProperty("paramB");
		} catch (IOException e) {
			System.out.println("装载配置文件出错");
			e.printStackTrace();
		} finally {
			try {
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}

}

